#source 'https://github.com/CocoaPods/Specs.git'
#source 'https://cdn.cocoapods.org/'
platform :ios, '10.0'
use_frameworks!
# 忽略第三方库的warning
#inhibit_all_warnings!

targetMap = {
    'Risac' => ['DeviceKit',
                'Moya',
                'SwiftyJSON',
                'SnapKit',
                'SwiftDate'],
    'Example' => ['Kingfisher']
}
targetMap.each do |key, value|
    target key do
        value.each do |p|
            pod p
        end
    end
end

# 仓库不通过podspec而是.swift-version文件指定swift版本时会指定为项目的swift版本
POD_SWIFT_VERSION_MAP = {}
post_install do |installer|
    installer.pods_project.targets.each do |target|
        # [XCBuildConfiguration(Release),XCBuildConfiguration(Debug)]
        release = target.build_configurations.first
        origin_swift_version = release.build_settings['SWIFT_VERSION']
        if POD_SWIFT_VERSION_MAP.include? target.name
            swift_version = POD_SWIFT_VERSION_MAP[target.name]
            puts "Setting ".green + "#{target.name}".bold.underlined.yellow + " Swift version from #{origin_swift_version} to #{swift_version}".green
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = swift_version
            end
        else
            puts "#{target.name}".bold.underlined.yellow + " Swift version: #{origin_swift_version}".green
        end
    end
end
